#include<iostream>
#include<string>
#include<vector>
using namespace std;

vector<string> s;
void Perm(string list, int k, int m)
{
	if (k == m)
	{
		string temp;
		for (int j = 0; j <= m; j++)
		{
			temp.push_back(list[j]);

		}
		if (find(s.begin(), s.end(), temp) == s.end())
			s.push_back(temp);

	}
	else
	for (int i = k; i <= m; i++)
	{
		swap(list[k], list[i]);
		Perm(list, k + 1, m);
		swap(list[k], list[i]);

	}
}
vector<string> Permutation(string str) {
	if (str.empty())
		return s;
	Perm(str, 0, str.size() - 1);

	return s;
}

int main()
{
	string n;
	cin >> n;
	Permutation(n);
	for (auto e : s)
		cout << e << " ";
	cout << endl;
}